package com.adingxiong.pm.mapper;

import com.adingxiong.pm.entity.Pmuser;
import com.adingxiong.pm.entity.vo.UserRoleVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xiongc
 * @since 2020-02-15
 */
public interface PmuserMapper extends BaseMapper<Pmuser> {

    /**
     * 查询出所有的用户 并查出其对应的角色
     * @param page
     * @return
     */
    @Select("SELECT user.*, depart.departmentname FROM pmuser user , department depart WHERE user.role = depart.id")
    List<UserRoleVo> getUserDeatilInfo (Page page);

    @Select("SELECT user.*, depart.departmentname FROM pmuser user , department depart WHERE user.role = depart.id  and " +
            "user.name LIKE CONCAT ('%',#{keywords},'%') or user.phone LIKE CONCAT ('%',#{keywords},'%') ")

    List<UserRoleVo>  findBykeywords (Page<UserRoleVo> page ,String keywords);

}
